package com.kai.steering.data.service.ctl;

import com.kai.steering.data.service.entity.dto.EmailRequest;
import com.kai.steering.data.service.service.EmailService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/email")
@Api(tags = "邮箱 API")
public class EmailController {
    @Autowired
    private EmailService emailService;

    @PostMapping("/sendEmail")
    public String sendEmail(@RequestParam("to") String to,
                            @RequestParam("subject") String subject,
                            @RequestParam("text") String text) {
        emailService.sendSimpleEmail(to, subject, text);
        return "Email sent successfully";
    }
    @PostMapping("/sendEmails")
    public String sendEmail(@RequestBody EmailRequest emailRequest) {
        emailService.sendSimpleEmail(emailRequest);
        return "Email sent successfully";
    }
    @PostMapping("/sendEmailFile")
    public String sendEmail(
                            @RequestParam("subject") String subject,
                            @RequestParam("text") String text) {
        emailService.sendSimpleEmail( subject, text);
        return "Email sent successfully";
    }
}
